package com.hig.ledger.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hig.ledger.domain.LedgerCertificates;
import com.hig.ledger.service.ILedgerCertificatesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 人员其他资质证件清单Controller
 * 
 * @author scp
 * @date 2024-09-22
 */
@RestController
@RequestMapping("/ledger/certificates")
public class LedgerCertificatesController extends BaseController
{
    @Autowired
    private ILedgerCertificatesService ledgerCertificatesService;

    /**
     * 查询人员其他资质证件清单列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:certificates:list')")
    @GetMapping("/list")
    public TableDataInfo list(LedgerCertificates ledgerCertificates)
    {
        startPage();
        List<LedgerCertificates> list = ledgerCertificatesService.selectLedgerCertificatesList(ledgerCertificates);
        return getDataTable(list);
    }

    /**
     * 导出人员其他资质证件清单列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:certificates:export')")
    @Log(title = "人员其他资质证件清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(LedgerCertificates ledgerCertificates, HttpServletResponse response)
    {
        List<LedgerCertificates> list = ledgerCertificatesService.selectLedgerCertificatesList(ledgerCertificates);
        ExcelUtil<LedgerCertificates> util = new ExcelUtil<LedgerCertificates>(LedgerCertificates.class);
        util.exportExcel(response,list, "人员其他资质证件清单");
    }

    /**
     * 获取人员其他资质证件清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('ledger:certificates:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ledgerCertificatesService.selectLedgerCertificatesById(id));
    }

    /**
     * 新增人员其他资质证件清单
     */
    @PreAuthorize("@ss.hasPermi('ledger:certificates:add')")
    @Log(title = "人员其他资质证件清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LedgerCertificates ledgerCertificates)
    {
        return toAjax(ledgerCertificatesService.insertLedgerCertificates(ledgerCertificates));
    }

    /**
     * 修改人员其他资质证件清单
     */
    @PreAuthorize("@ss.hasPermi('ledger:certificates:edit')")
    @Log(title = "人员其他资质证件清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LedgerCertificates ledgerCertificates)
    {
        return toAjax(ledgerCertificatesService.updateLedgerCertificates(ledgerCertificates));
    }

    /**
     * 删除人员其他资质证件清单
     */
    @PreAuthorize("@ss.hasPermi('ledger:certificates:remove')")
    @Log(title = "人员其他资质证件清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ledgerCertificatesService.deleteLedgerCertificatesByIds(ids));
    }
}
